text
Functions
Compares this text to another text lexicographically, based on the Unicode value of each character in each text object.
Compares this text to another text lexicographically, based on the Unicode value of each character in each text object.
Converts this text to an array of UTF-8 encoded bytes.
Uses this text as a format string and returns the text obtained by substituting the specified arguments.
Supports many of the format specifiers found in other programming languages, including:
%s
fortext
%d
forinteger
s andbig_integer
s in decimal (base 10) representation%o
forinteger
s andbig_integer
s in octal (base 8) representation%x
forinteger
s andbig_integer
s in hexadecimal (base 16) representation%f
fordecimal
(supports precision, e.g.%.2f
for two decimal places)%b
forboolean
s (output in lower-case, i.e.true
andfalse
)%B
forboolean
s (output in upper-case, i.e.TRUE
andFALSE
)
Examples:
'My integer is %d.'.format(123)
returns'My integer is 123.'
.'See you...%10s.'.format('later')
returns'See you... later.'
.'Earnings: daily=%f, weekly=%f, monthly=%f.'.format(312.45, 534.78, 2199.67)
returns'Earnings: daily=312.450000, weekly=534.780000, monthly=2199.670000.'
.''%d %o %x'.format(14, 14, 14)'
returns'14 16 e'
.
If any format specifier is incompatible with the type of its corresponding argument, or if there are more specifiers requiring substitution than there are arguments, all format specifiers are left unsubstituted in the output text.
All format specifiers are also left unsubstituted in the output text when any argument is null
, except when it matches the specifier is %s
, in which case the text 'null'
is substituted (assuming the other arguments and specifiers are correctly matched).
If there are more arguments than format specifiers, the extra arguments are ignored, but matched arguments are still substituted (assuming they match correctly).
Create a text representation of the given bytes.
By default, an exception is thrown if invalid UTF-8 characters are encountered, however if the optional parameter ignore_errors
is provided as true
, invalid characters are instead replaced with a placeholder.
Search for the first occurrence of the specified substring within this text.
Returns the position of the first occurrence of the specified substring within this text, starting at the specified index, or -1 if the text is not found.
Search for the first occurrence of the specified substring within this text.
Returns the position of the first occurrence of the specified substring within this text, starting at the specified index, or -1 if the text is not found.
Returns the index within this text of the last occurrence of the specified string, or -1 if not found.
Returns the index within this text of the last occurrence of the specified string, starting from the specified startIndex, or -1 if not found.
Returns the index within this text of the last occurrence of the specified string, or -1 if not found.
Returns the index within this text of the last occurrence of the specified string, starting from the specified startIndex, or -1 if not found.
Matches this text against the specified SQL LIKE pattern.
Use '_'
to match any single character, and '%'
to match any sequence of zero or more characters. The escape sequences '\\_'
, '\\%'
and '\\\\'
match the literal characters '_'
, '%'
and '\'
respectively.
Examples:
val names = ["Alice", "Victor", "Viktor", "Victoria", "V\\ctor"];
print(names @* { .like("Vi_tor") }); // prints [Victor, Viktor]
print(names @* { .like("Vic%") }); // prints [Victor, Victoria]
print(names @* { .like("V\\\\c%") }); // prints [V\ctor]
Returns the text obtained by converting all alphabetic characters in this text to lower case.
Returns the text obtained by converting all alphabetic characters in this text to lower case.
Matches this text against the specified regular expression.
Regular expressions use the same syntax as java.util.regex.Pattern
.
Examples:
val names = ["Alice", "Victor", "Viktor", "Victoria", "V\\ctor"];
print(names @* { .matches("Vi[a-z]tor") }); // prints [Victor, Viktor]
print(names @* { .matches("Vic.*") }); // prints [Victor, Victoria]
print(names @* { .matches("V\\\\c.*") }); // prints [V\ctor]
Splits this text around matches of the given delimiter.
Examples:
'the cow jumped over the moon'.split(' ')
returns['the', 'cow', 'jumped', 'over', 'the', 'moon']
.'giggling'.split('g')
returns['', 'i', '', 'lin', '']
.'espresso'.split('a')
returns['espresso']
.
Checks if this text starts with the specified prefix.
Note that for all texts t
, t.starts_with('')
is true, and for all texts u
and v
such that u == v
, u.starts_with(v)
is true.
Checks if this text starts with the specified prefix.
Note that for all texts t
, t.starts_with('')
is true, and for all texts u
and v
such that u == v
, u.starts_with(v)
is true.
Converts this text to an array of UTF-8 encoded bytes.
Returns the text obtained by converting all alphabetic characters in this text to upper case.
Returns the text obtained by converting all alphabetic characters in this text to upper case.